(function(window){
  var app = {};
  //1111
  //接口服务器地址
  // app.webUrl = "http://wx191210.slyz.info:580";
  
  app.webUrl = "";
  //app.webUrl = "http://10.193.1.248";//学校ip
  // app.webUrl = "http://121.196.121.241";//租号服务器地址
  /**
       * ///
     * @description 进行支付密码的双md5加密
     * @param {value} 传入的密码
     * @return 返回密码的双md5加密
     */
    app.doublemd5 = function(value){
      var val = md5(value).toString().substring(0, 32);
      return md5(val).toString().substring(0, 32);
  };
  // 依赖jquery
  app.alert=function(value){
                  $("body").append("<span class = 'msgalert'>"+value+"</span>");
                    setTimeout(function () {
                        $('.msgalert').remove();
                    }, 1000);
  }
//   切换input框的隐藏显示
app.hide_input_text=function(dom){
    // dom为jq对象，input框
    var type = dom.attr('type');
    if(type == 'text'){
        dom.attr('type','password')
    }else{
        dom.attr('type','text');
    }
}
  /**
 * [通过参数名获取url中的参数值]
 * 示例URL:http://htmlJsTest/getrequest.html?uid=admin&rid=1&fid=2&name=小明
 * @param  {[string]} queryName [参数名]
 * @return {[string]}           [参数值]
 */
app.GetQueryValue = function (queryName) {
  // var query = window.location.href;
  // console.log(query);
  // var vars = query.split("&");
  // for (var i = 0; i < vars.length; i++) {
  //     var pair = vars[i].split("=");
  //     if (pair[0] == queryName) { return pair[1]; }
  // }
  // return null;
  var reg = new RegExp("(^|&)" + queryName + "=([^&]*)(&|$)", "i");   
  var r = window.location.href.substr(1).match(reg);   
  if (r != null) return decodeURI(r[2]); return null;   
}

// 监听滚动条方法
app.whatch_scroll = function(dom,cb){
    // dom为一个jquery对象
    // 监听滚动条底部的距离
    var mdom = dom.get(0);  
    dom.scroll(function(){
        var boheight = mdom.scrollHeight -mdom.scrollTop -mdom.clientHeight;
        if(boheight<5){
            // console.log(this);
            // console.log(boheight);
            if(typeof cb == 'function'){
                cb();
            }
        }
        
    })
}
//倒计时
  /**
 
 * @param  {[string]} time [截止时间]
 * @return {[string]}    showtime       [展示的时间]
 */
app.daojishi=function(time,showtime){
    var starttime = new Date(time); //时间一定要new Data一下
    setInterval(function () {
    var nowtime = new Date();
    var time = starttime - nowtime;
    var day = parseInt(time / 1000 / 60 / 60 / 24);
    var hour = parseInt(time / 1000 / 60 / 60 % 24);
    var minute = parseInt(time / 1000 / 60 % 60);
    var seconds = parseInt(time / 1000 % 60);
    showtime=(day + "天" + hour + "小时" + minute + "分钟" + seconds + "秒");
    }, 1000);
}
// 依赖vant
app.toastLoading = function(msg){
  if(!msg){
    msg = '';
  }
  vant.Toast.loading({
    duration: 0, // 持续展示 toast
    forbidClick: true,
    message: msg
  });
}
app.toastClear = function(){
  vant.Toast.clear();
}
// 图片预览，依赖vant

app.imgPre = function(src){
  vant.ImagePreview({
      images:[src],
      closeable: true
  });
}
//弹窗
app.text_show=function(text){
  vant.Dialog({ 
    message: text,
    showConfirmButton:false,
    closeOnClickOverlay:true,
 });
 setTimeout(() => {
 $(".van-overlay").click()
 }, 1000);
},
//判断当前时间是否在开始和结束时间之间
// start_time:"09:00:00"
app.judge_time = function(start_time,end_time){
  var start_time_arr = start_time.split(":");
  var start_h = Number(start_time_arr[0]),
      start_mi = Number(start_time_arr[1]),
      start_s = Number(start_time_arr[2]);
  var end_time_arr = end_time.split(":");
  var end_h = Number(end_time_arr[0]),
      end_mi = Number(end_time_arr[1]),
      end_s = Number(end_time_arr[2]);
  var date = new Date();
  var h = date.getHours(),
      mi = date.getMinutes(),
      s = date.getSeconds();
  // 比较,全都换算为秒
  var start_num = start_h*60*60+start_mi*60+start_s;
  var end_num = end_h*60*60+end_mi*60+end_s;
  var now_num = h*60*60 + mi*60 +s;
  if(start_num <= now_num && end_num >= now_num){
    return true;
  }else{
    return false;
  }
}

//弹窗

  window.app = app;
}(window))
